﻿using Comm.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Comm.Web.Action
{
    /// <summary>
    /// UserOrder 的摘要说明
    /// </summary>
    public class UserOrder : BaseHander
    {
        BLL.BooksService bllbook = new BLL.BooksService();
        protected string strtype = string.Empty;
        public override void SonLoad()
        {
            string type = Request.Params["type"];
            switch (type)
            {
                case "view":
                    CreateStaticPage();
                    break;
                case "Edit":
                    CreateViewStaticPage();
                    break;
            }
        }

        public void CreateStaticPage()
        {
            try
            {
                strtype = "true";
                int bookId = int.Parse(Request.Form["bookId"]);
                string htmlPath = bllbook.CreateStaticPage(bookId, strtype);
                AjaxMsgHelper.AjaxMsg("ok", "生成成功！~~", JsonHelper.Serialize(htmlPath));
            }
            catch (Exception ex)
            {
                AjaxMsgHelper.AjaxMsg("err", ex.Message);
            }
        }

        public void CreateViewStaticPage()
        {
            try
            {
                strtype = "false";
                int bookId = int.Parse(Request.Form["bookId"]);
                string htmlPath = bllbook.CreateStaticPage(bookId, strtype);
                AjaxMsgHelper.AjaxMsg("ok", "生成成功！~~", JsonHelper.Serialize(htmlPath));
            }
            catch (Exception ex)
            {
                AjaxMsgHelper.AjaxMsg("err", ex.Message);
            }
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}